package cn.com.nes.site.entity.em.project;

import cn.com.nes.common.exception.NoSuchEnumException;

import java.util.HashMap;
import java.util.Map;

/**
 * 项目关系类型 枚举
 *
 */
public enum ProjectRelationTypeEnum {

    OTHER(0, "从客户"),
    MAIN(1, "主客户"),
    ;

    private final Integer key;
    private final String value;

    ProjectRelationTypeEnum(int key, String value) {
        this.key = key;
        this.value = value;
    }

    public Integer getKey() {
        return key;
    }

    public String getValue() {
        return value;
    }

    public static ProjectRelationTypeEnum getKey(String key) {
        Map<String, ProjectRelationTypeEnum> map = new HashMap<>();
        for (ProjectRelationTypeEnum projectRelationTypeEnum : values()) {
            map.put(String.valueOf(projectRelationTypeEnum.getKey()), projectRelationTypeEnum);
        }
        if (!map.containsKey(key)) {
            throw new NoSuchEnumException("未匹配的项目关系类型");
        }
        return map.get(key);
    }

}
